package com.tjvib.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.tjvib.R;
import com.tjvib.bean.OrderBean;
import com.tjvib.util.ToastUtil;

import java.util.List;

public class OrderAdapter extends BaseQuickAdapter<OrderBean, BaseViewHolder> {
    public OrderAdapter(int layoutResId) {
        super(layoutResId);
    }

    public OrderAdapter(int layoutResId, @Nullable List<OrderBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, OrderBean orderBean) {
        baseViewHolder.setText(R.id.item_order_tv_tit, orderBean.getTitle())
                .setText(R.id.item_order_tv_id, "订单ID："+orderBean.getId())
                .setText(R.id.item_order_tv_time, orderBean.getTime())
                .setText(R.id.item_order_tv_money, orderBean.getMoney());

        String preType = orderBean.isType() == 0 ? "微信" : "支付宝";
        if (orderBean.isPay()) {
            baseViewHolder.setText(R.id.item_order_tv_pay, preType + "支付成功");
            baseViewHolder.setBackgroundResource(R.id.item_order_v_pay, R.drawable.shape_circle_green);
        } else {
            baseViewHolder.setText(R.id.item_order_tv_pay, preType + "支付失败");
            baseViewHolder.setBackgroundResource(R.id.item_order_v_pay, R.drawable.shape_circle_red);
        }
    }
}
